<?php

/**
 * openapi 自定义异常
 * @author dean
 */

namespace api\modules\openapi\components\exception;

/**
 *
 * 
 */
class OpenApiException extends \yii\web\HttpException
{
    
    public function __construct($message = null, $code = 0, \Exception $previous = null)
    {
        parent::__construct(400, $message, $code, $previous);
    }
    
    public function getErrorMessage(){
        //如果抛出异常时第一个参数填了message则用message 否则用errormap定义的
        if(isset($this->message) && !empty($this->message)){
            return $this->message;
        }
        return OpenApiErrorMap::getMessage($this->code);
    }
    
}
